Public Function DecodeImage(ByVal MFDClass As MultiFrameData, ByVal Index As Long, MIMEType As String, PictureType As PictureType, Pic As StdPicture, ByVal ID3Revision As Byte, Optional OrigPicData As String) As Boolean
On Error GoTo err
Dim bRet As Boolean
Dim sMIMEType As String
Dim tMIMEType As String
Dim lPicType As PictureType
Dim GPC As GDIPlusCandy
Dim sPic As StdPicture
Dim sValue As String
Dim i As Long
bRet = False
MIMEType = ""
PictureType = OtherPicType
Set Pic = Nothing
OrigPicData = ""
sValue = MFDClass(Index)
If ID3Revision > 2 Then i = InStr(sValue, Chr$(0)) Else i = 4
If i > 0 Then
sMIMEType = Left$(sValue, i - 1)
If sMIMEType = "-->" Then GoTo err ' Skip image URLs
sValue = Mid$(sValue, i + 1 * Abs(ID3Revision > 2))
lPicType = Asc(Left$(sValue, 1))
If lPicType > PublisherLogotype Then lPicType = OtherPicType ' Fix invalid picture type
sValue = Mid$(sValue, 2)
If Left$(sValue, 1) = Chr$(0) Then ' Skip frames with descriptions
If sMIMEType <> tMIMEType And tMIMEType <> ImageUnsupported Then
sMIMEType = tMIMEType
End If
MIMEType = sMIMEType
If lPicType = FileIcon32x32 Then
If sMIMEType <> ImagePNG Or HimetricToPixelsX(sPic.Width) <> 32 Or HimetricToPixelsY(sPic.Height) <> 32 Then
lPicType = OtherFileIcon
End If
End If
PictureType = lPicType
Set Pic = sPic
OrigPicData = sValue
bRet = True
End If
End If
End If
err:
DecodeImage = bRet
End Function
' Insert data WITHOUT encoding
Public Sub InsertImageData(MFDClass As MultiFrameData, ByVal Index As Long, ByVal MIMEType As String, ByVal PictureType As PictureType, ByVal Data As String, ByVal ID3Revision As Byte)
On Error GoTo err
Dim lPicType As PictureType: lPicType = PictureType
Dim sMIMEType As String
Dim tMIMEType As String
Dim GPC As GDIPlusCandy
Dim sPic As StdPicture
sMIMEType = MIMEType
tMIMEType = DetermineImageType(Data, ID3Revision)
If sMIMEType <> tMIMEType And tMIMEType <> ImageUnsupported Then
sMIMEType = tMIMEType
End If
Set GPC = New GDIPlusCandy
Set sPic = GPC.DataToImage(Data)
Set GPC = Nothing
If Not sPic Is Nothing Then ' Do not insert the data if invalid
If lPicType = FileIcon32x32 Then
If MIME(sMIMEType, ID3Revision) <> ImagePNG Or HimetricToPixelsX(sPic.Width) <> 32 Or HimetricToPixelsY(sPic.Height) <> 32 Then
Public Sub InsertImage(MFDClass As MultiFrameData, ByVal Index As Long, ByVal MIMEType As String, ByVal PictureType As PictureType, ByVal Pic As StdPicture, ByVal ID3Revision As Byte)
On Error GoTo err
Dim lPicType As PictureType: lPicType = PictureType